﻿@using ECGadmin.WebUI.CustomHelpers
@using ECGadmin.WebUI.Models
@model IEnumerable<ECGadmin.Common.SizeListDto>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_layout.cshtml";
}
@section LeftMenu
{
    <div id="left">
        <div class="LeftMenuWraper">
            <div class="leftMenuHeader">
                <span style="padding-left: 10px;">
                    <strong>Truy cập nhanh</strong>
                </span>
            </div>
            <ul id="p-quick-menu" class="quick-menu">
                <li class="qmn-info-pro">
                    <a href="@Url.Action("Index", "Color")">Mầu sắc</a>
                </li>
                <li class="qmn-seo-pro">
                    <a href="@Url.Action("Index", "Size")">Kích cỡ</a>
                </li>
            </ul>
            <div class="leftMenuFooter"></div>
        </div>
    </div>
    <!-- END #left -->
}
<nav>
    <div id="jCrumbs" class="breadCrumb module">
        <ul>
            <li><a href="@Url.Action("Index","Home")"><i class="bootstrap icon-home"></i></a></li>
            <li><a href="javascript:void(0)">Danh sách Size</a> </li>
        </ul>
    </div>
</nav>
<div class="toolBox">
    @Html.ToolBox(new List<object> { new Add { ClassCss = "Add", ActionName = "/Size/Add" } })
</div>
<table class="table-odd table-plist">
    <tr>
        <th>STT</th>
        <th>Tên size</th>
        <th>Mã</th>
        <th></th>
    </tr>
    @foreach(var item in Model)
    {
        <tr>
            <td>@item.STT</td>
            <td>
                @item.SizeName
            </td>
            <td>
                @item.Code
            </td>
            <td>
                <a href="@Url.Action("Edit", "Size", new { id = @item.Id })">Edit</a>
                <a href="javascript:void(0);" onclick="DeleteSize(@item.Id)">Xóa</a>
            </td>
        </tr>
    }
</table>
<div class="p-paging">
    @Html.PageLinks((PageInfo)ViewBag.PageInfo, i => Url.Action("Index", "Size", new { page = i }))
</div>
@section scripts
{
    <script type="text/javascript">
        function DeleteSize(id) {
            $.ajax({
                url: '/Size/DeleteSize',
                data: { id: id },
                success: function (data) {
                    if(data) {
                        alert('Xóa size thành công!');
                        window.location = '/Admin/Size';
                    }else {
                        alert('Size đã có sản phẩm!');
                    }
                },
                error: function () {
                    alert('Đã có lỗi xảy ra!');
                }
            });
        }
    </script>
}